﻿using Quartz;
using Quartz.Impl;
using System;

namespace Dapper_Core.AutoJob
{
    public class SchedulerGenerator
    {
        private static object lockHelper = new object();

        private static IScheduler scheduler = null;
        public static IScheduler GetScheduler()
        {
            if (scheduler == null)
            {
                lock (lockHelper)
                {
                    if (scheduler != null)
                    {
                        return scheduler;
                    }
                    else
                    {
                        ISchedulerFactory schedf = new StdSchedulerFactory();
                        IScheduler sched = schedf.GetScheduler().Result;
                        return sched;
                    }
                }
            }
            return scheduler;
        }
    }
}
